// pages/site/addsite/index.js
const app = getApp() // 引入app
const _request = require("../../../utils/request.js"); // 引入require
// 引入SDK核心类，js文件根据自己业务，位置可自行放置
var QQMapWX = require('../../../utils/qqmap-wx-jssdk.min.js');
var qqmapsdk
const area = require('../../../utils/area');
Page({
  data: {
    show: false,
    areaList: area.areaList,
    name:'',
    city: '',
    address:'',
  },
  getname(e){
    this.setData({
      name:e.detail.value
    })
  },
  getaddress(e){
    this.setData({
      address:e.detail.value
    })
  },
  showmolde() {
    this.setData({
      show: true
    });
  },
  onClose() {
    this.setData({
      show: false
    });
  },
  onFirm(e) {
    console.log(e);
    this.setData({
      show: false,
      city: e.detail.values.map(item=>{
        return item.name 
      })
    });
  },
  onAdd(){
    if (!this.data.name) {
      wx.showToast({ title: "请输入门店名称",icon: 'none' })
      return;
    }
    if (!this.data.city) {
      wx.showToast({ title: "请选择地区",icon: 'none' })
      return;
    }
    if (!this.data.address) {
      wx.showToast({ title: "请输入详细地址",icon: 'none' })
      return;
    }
    var authinfo = app.globalData.authinfo
    _request.postObj('/storeAuthApply/save', {
      realname:authinfo.realname,
      cardno:authinfo.cardno,
      licenseno:authinfo.licenseno,
      businesslicensePath:authinfo.businesslicensePath,
      bannerPath:authinfo.bannerPath,
      storephotosPaths:authinfo.storephotosPaths,
      handIDcardPath:authinfo.handIDcardPath,
      storeId:wx.getStorageSync('storeId'),
    }).then((res) => {
      if (res.data.code == 200) {
        wx.showToast({
          title: "上传成功",
          icon: 'none',
        })
        setTimeout(() => {
          wx.switchTab({
            url: '/firstpages/home/index',
          })
        }, 2000);
      }
    })
  },
  // 授权定位权限
  // getLocation() {
  //   var _this = this
  //   wx.chooseLocation({
  //     success:function(res){
  //       _this.setData({
  //         city:res.address,
  //         address:res.name
  //       })
  //     }
  //   })
  // },
})